<template>
	<div class="systemRolePage">
		<div class="strategyMenus">
			<div class="listAdd">
				<wj-Button type="save" @click="roleAdd">
					<i class="wj-icon-tianjia"></i>
					新建角色
				</wj-Button>
			</div>
			<div class="strategyMenusSearch">
				<el-input placeholder="请输关键字检索" type="text" v-model="searchValue"></el-input>
			</div>
			<div class="strategyMenusBut">
				<wj-Button type="save" @click="searchEvent">查询</wj-Button>
			</div>
		</div>
		<div class="strategyList">
			<div class="listContent">
				<el-table
					:data="tableData"
					style="width: 100%"
					:default-sort="{ prop: 'roleName', order: 'descending' }"
					:row-class-name="'tableRowClassName'"
				>
					<el-table-column type="index" width="80" label="序号"> </el-table-column>
					<el-table-column prop="roleName" label="角色名称" sortable width="180"> </el-table-column>
					<el-table-column prop="serialNumber" label="排序号码" width="180"> </el-table-column>
					<el-table-column prop="note" label="描述信息"> </el-table-column>
					<el-table-column prop="status" label="角色状态">
						<template slot-scope="scope">
							<wj-Button type="save" v-if="scope.row.status == 0">{{ "已启用" }}</wj-Button>
							<wj-Button type="reset" v-if="scope.row.status == 1">{{ "已禁用" }}</wj-Button>
						</template>
					</el-table-column>
					<el-table-column prop="updateLastTime" label="最后修改日期"> </el-table-column>
					<el-table-column label="操作" width="180">
						<template slot-scope="scope">
							<el-link type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-link>
							<el-dropdown @command="handleCommand">
								<span class="el-dropdown-link">
									<el-link type="primary">更多</el-link>
								</span>
								<el-dropdown-menu slot="dropdown">
									<!-- <el-dropdown-item :command="{ obj: scope.row, value: '授权菜单' }">授权菜单</el-dropdown-item> -->
									<el-dropdown-item :command="{ obj: scope.row, value: '删除' }">删除</el-dropdown-item>
								</el-dropdown-menu>
							</el-dropdown>
						</template>
					</el-table-column>
				</el-table>
			</div>
		</div>
		<div class="strategyPage">
			<el-pagination
				background
				@size-change="handleSizeChange"
				@current-change="handleCurrentChange"
				:current-page="currentPage"
				:page-sizes="[9]"
				:page-size="pageSize"
				layout="total, prev, pager, next, jumper"
				:total="total"
			>
			</el-pagination>
		</div>
		<!-- 自定义alertBox弹框——详情 -->
		<AlertBox :alertBoxVisible="alertBoxIssueVisible">
			<div class="contentBox contentBoxDetailsRole_class">
				<div class="contentBox_header">
					<p>编辑角色信息</p>
					<i class="wj-icon-guanbi" @click="alertBoxFormclose"></i>
				</div>
				<div class="contentBox_body">
					<div class="infoRow_form">
						<span>角色名称<b style="color: rgb(248, 4, 4)">*</b></span>
						<div class="form-item">
							<el-input v-model="roleEdit.roleName" placeholder="请输入角色名称" v-validate="'required'"></el-input>
						</div>
					</div>
					<div class="infoRow_form">
						<span>排序号码<b style="color: rgb(248, 4, 4)">*</b></span>
						<div class="form-item">
							<el-input v-model="roleEdit.roleNumber" placeholder="请输入排序号码" v-validate="'required|pin'"></el-input>
						</div>
					</div>
					<div class="infoRow_form_textarea">
						<span>描述信息</span>
						<div class="form-textarea">
							<el-input type="textarea" :rows="2" placeholder="请输入描述信息" v-model="roleEdit.roleDes"> </el-input>
						</div>
					</div>
					<div class="infoRow_form">
						<span>是否启用</span>
						<div class="form-item">
							<el-switch v-model="roleEdit.roleState" @change="handleSwitch" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
						</div>
					</div>
					<div class="infoRow_form">
						<span>最后修改</span>
						<span class="form-span">{{ roleEdit.roleEndtime }}</span>
					</div>
					<div class="infoRow_form_menu">
						<span>授权菜单</span>
						<div class="form-menu">
							<!-- <el-checkbox v-model="roleEdit.homePage" label="控制台" :disabled="roleEdit.monitor || roleEdit.monitorApprove"></el-checkbox> -->
							<el-checkbox
								v-model="roleEdit.securityAudit"
								label="安全审计"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.realTimeWarning"
								label="实时告警"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<!-- <el-checkbox v-model="roleEdit.workOrder" label="工单管理" :disabled="roleEdit.monitor || roleEdit.monitorApprove"></el-checkbox> -->
							<el-checkbox
								v-model="roleEdit.terminalManage"
								label="设备管理"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.releaseResourceAllow"
								label="发布源准入"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.policyRelease"
								label="策略配置"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.systemAudit"
								label="内部审计"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<!-- <el-checkbox v-model="roleEdit.securityProtective" label="安全防护" :disabled="roleEdit.monitor || roleEdit.monitorApprove"></el-checkbox> -->
							<!-- <el-checkbox
								v-model="roleEdit.syslogConfig"
								label="Syslog配置"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox> -->
							<el-checkbox
								v-model="roleEdit.systemConfig"
								label="系统设置"
								:disabled="roleEdit.monitor || roleEdit.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.monitor"
								label="监控组"
								:disabled="roleEdit.monitorApprove"
								@change="handleMonitor"
							></el-checkbox>
							<el-checkbox
								v-model="roleEdit.monitorApprove"
								label="监控组管理员"
								:disabled="roleEdit.monitor && !roleEdit.monitorApprove"
								@change="handleMonitorApprove"
							></el-checkbox>
						</div>
					</div>
				</div>
				<div class="contentBox_footer">
					<wj-Button type="save" v-checksubmit="{ submitEvent: handleEditConfirm, cls: 'contentBoxDetailsRole_class' }">确定</wj-Button>
				</div>
			</div>
		</AlertBox>
		<!-- 自定义alertBox弹框——新增 -->
		<AlertBox :alertBoxVisible="alertBoxAddVisible">
			<div class="contentBox contentBoxAddRole_class">
				<div class="contentBox_header">
					<p>新增角色信息</p>
					<i class="wj-icon-guanbi" @click="alertBoxAddclose"></i>
				</div>
				<div class="contentBox_body">
					<div class="infoRow_form">
						<span>角色名称<b style="color: rgb(248, 4, 4)">*</b></span>
						<div class="form-item">
							<el-input v-model="roleAddData.roleName" placeholder="请输入角色名称" v-validate="'required'"></el-input>
						</div>
					</div>
					<div class="infoRow_form">
						<span>排序号码<b style="color: rgb(248, 4, 4)">*</b></span>
						<div class="form-item">
							<el-input v-model="roleAddData.roleNumber" placeholder="请输入排序号码" v-validate="'required|pin'"></el-input>
						</div>
					</div>
					<div class="infoRow_form_textarea">
						<span>描述信息</span>
						<div class="form-textarea">
							<el-input type="textarea" :rows="2" placeholder="请输入描述信息" v-model="roleAddData.roleDes"> </el-input>
						</div>
					</div>
					<div class="infoRow_form">
						<span>是否启用</span>
						<div class="form-item">
							<el-switch v-model="roleAddData.roleState" @change="handleSwitch" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
					</div>
					<div class="infoRow_form_menu">
						<span>授权菜单</span>
						<div class="form-menu">
							<!-- <el-checkbox v-model="roleAddData.homePage" label="控制台" :disabled="roleAddData.monitor || roleAddData.monitorApprove"></el-checkbox> -->
							<el-checkbox
								v-model="roleAddData.securityAudit"
								label="安全审计"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleAddData.realTimeWarning"
								label="实时告警"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<!-- <el-checkbox v-model="roleAddData.workOrder" label="工单管理" :disabled="roleAddData.monitor || roleAddData.monitorApprove"></el-checkbox> -->
							<el-checkbox
								v-model="roleAddData.terminalManage"
								label="设备管理"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleAddData.releaseResourceAllow"
								label="发布源准入"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleAddData.policyRelease"
								label="策略配置"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleAddData.systemAudit"
								label="内部审计"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<!-- <el-checkbox v-model="roleAddData.securityProtective" label="安全防护" :disabled="roleAddData.monitor || roleAddData.monitorApprove"></el-checkbox> -->
							<el-checkbox
								v-model="roleAddData.syslogConfig"
								label="Syslog配置"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox
								v-model="roleAddData.systemConfig"
								label="系统设置"
								:disabled="roleAddData.monitor || roleAddData.monitorApprove"
							></el-checkbox>
							<el-checkbox v-model="roleAddData.monitor" label="监控组" :disabled="roleAddData.monitorApprove"></el-checkbox>
							<el-checkbox
								v-model="roleAddData.monitorApprove"
								label="监控组管理员"
								:disabled="roleAddData.monitor && !roleAddData.monitorApprove"
							></el-checkbox>
						</div>
					</div>
				</div>
				<div class="contentBox_footer">
					<wj-Button type="save" v-checksubmit="{ submitEvent: roleAddConfirm, cls: 'contentBoxAddRole_class' }">确定</wj-Button>
				</div>
			</div>
		</AlertBox>
	</div>
</template>
<script>
import { system_role_all, system_role_delete, system_role_add, system_role_Edit } from "@/utils/request/api";
export default {
	name: "SystemRole",
	data() {
		return {
			// 搜索
			searchValue: "",
			// 分页当前页码
			currentPage: 1,
			// 总页码
			total: 0,
			// 每页条数
			pageSize: 10,
			// 分页初始化页码
			pageNum: 1,
			// 表格数据
			tableData: [
				// {
				// 	roleName: "审计员",
				// 	ordering: "100",
				// 	describe: "管理系统审计信息",
				// 	roleState: "已启用",
				// 	roleUpdateEnd: "2021-10-31 16:01",
				// },
				// {
				// 	roleName: "普通用户",
				// 	ordering: "101",
				// 	describe: "普通用户",
				// 	roleState: "已启用",
				// 	roleUpdateEnd: "2021-10-31 16:01",
				// },
				// {
				// 	roleName: "审计员",
				// 	ordering: "100",
				// 	describe: "管理系统审计信息",
				// 	roleState: "已禁用",
				// 	roleUpdateEnd: "2021-10-31 16:01",
				// },
				// {
				// 	roleName: "普通用户",
				// 	ordering: "101",
				// 	describe: "普通用户",
				// 	roleState: "已禁用",
				// 	roleUpdateEnd: "2021-10-31 16:01",
				// },
				// {
				// 	roleName: "审计员",
				// 	ordering: "100",
				// 	describe: "管理系统审计信息",
				// 	roleState: "已启用",
				// 	roleUpdateEnd: "2021-10-31 16:01",
				// },
			],
			// 自定义弹窗控制——详情
			alertBoxIssueVisible: false,
			// 自定义弹窗控制——新增
			alertBoxAddVisible: false,
			// 编辑
			roleEdit: {
				roleId: "",
				roleName: "",
				roleNumber: "",
				roleDes: "",
				roleState: false,
				roleEndtime: "",
				homePage: false,
				securityAudit: false,
				realTimeWarning: false,
				workOrder: false,
				terminalManage: false,
				releaseResourceAllow: false,
				policyRelease: false,
				systemAudit: false,
				securityProtective: false,
				syslogConfig: false,
				systemConfig: false,
				monitor: false,
				monitorApprove: false,
			},
			// 新增
			roleAddData: {
				roleName: "",
				roleNumber: "",
				roleDes: "",
				roleState: false,
				homePage: false,
				securityAudit: false,
				realTimeWarning: false,
				workOrder: false,
				terminalManage: false,
				releaseResourceAllow: false,
				policyRelease: false,
				systemAudit: false,
				securityProtective: false,
				syslogConfig: false,
				systemConfig: false,
				monitor: false,
				monitorApprove: false,
			},
		};
	},
	created() {},
	mounted() {
		this.roleAllInfo(this.pageNum, this.pageSize);
	},
	watch: {
		// "roleEdit.monitor": {
		// 	handler(newVal, oldVal) {
		// 		console.log(newVal, oldVal);
		// 		if (newVal) {
		// 			this.roleEdit.homePage = false;
		// 			this.roleEdit.securityAudit = false;
		// 			this.roleEdit.realTimeWarning = false;
		// 			this.roleEdit.workOrder = false;
		// 			this.roleEdit.terminalManage = false;
		// 			this.roleEdit.releaseResourceAllow = false;
		// 			this.roleEdit.policyRelease = false;
		// 			this.roleEdit.systemAudit = false;
		// 			this.roleEdit.securityProtective = false;
		// 			this.roleEdit.syslogConfig = false;
		// 			this.roleEdit.systemConfig = false;
		// 			// this.roleEdit.monitorApprove = false;
		// 		}
		// 	},
		// 	immediate: true,
		// 	deep: true,
		// },
		"roleAddData.monitor": {
			handler(newVal, oldVal) {
				console.log(newVal, oldVal);
				if (newVal) {
					this.roleAddData.homePage = false;
					this.roleAddData.securityAudit = false;
					this.roleAddData.realTimeWarning = false;
					this.roleAddData.workOrder = false;
					this.roleAddData.terminalManage = false;
					this.roleAddData.releaseResourceAllow = false;
					this.roleAddData.policyRelease = false;
					this.roleAddData.systemAudit = false;
					this.roleAddData.securityProtective = false;
					this.roleAddData.syslogConfig = false;
					this.roleAddData.systemConfig = false;
					// this.roleAddData.monitorApprove = false;
				}
			},
			immediate: true,
			deep: true,
		},
		// "roleEdit.monitorApprove": {
		// 	handler(newVal, oldVal) {
		// 		console.log(newVal, oldVal);
		// 		if (newVal) {
		// 			this.roleEdit.homePage = false;
		// 			this.roleEdit.securityAudit = false;
		// 			this.roleEdit.realTimeWarning = false;
		// 			this.roleEdit.workOrder = false;
		// 			this.roleEdit.terminalManage = false;
		// 			this.roleEdit.releaseResourceAllow = false;
		// 			this.roleEdit.policyRelease = false;
		// 			this.roleEdit.systemAudit = false;
		// 			this.roleEdit.securityProtective = false;
		// 			this.roleEdit.syslogConfig = false;
		// 			this.roleEdit.systemConfig = false;
		// 			this.roleEdit.monitor = true;
		// 		} else {
		// 			this.roleEdit.homePage = false;
		// 			this.roleEdit.securityAudit = false;
		// 			this.roleEdit.realTimeWarning = false;
		// 			this.roleEdit.workOrder = false;
		// 			this.roleEdit.terminalManage = false;
		// 			this.roleEdit.releaseResourceAllow = false;
		// 			this.roleEdit.policyRelease = false;
		// 			this.roleEdit.systemAudit = false;
		// 			this.roleEdit.securityProtective = false;
		// 			this.roleEdit.syslogConfig = false;
		// 			this.roleEdit.systemConfig = false;
		// 			this.roleEdit.monitor = false;
		// 		}
		// 	},
		// 	immediate: true,
		// 	deep: true,
		// },
		"roleAddData.monitorApprove": {
			handler(newVal, oldVal) {
				console.log(newVal, oldVal);
				if (newVal) {
					this.roleAddData.homePage = false;
					this.roleAddData.securityAudit = false;
					this.roleAddData.realTimeWarning = false;
					this.roleAddData.workOrder = false;
					this.roleAddData.terminalManage = false;
					this.roleAddData.releaseResourceAllow = false;
					this.roleAddData.policyRelease = false;
					this.roleAddData.systemAudit = false;
					this.roleAddData.securityProtective = false;
					this.roleAddData.syslogConfig = false;
					this.roleAddData.systemConfig = false;
					this.roleAddData.monitor = true;
				} else {
					this.roleAddData.homePage = false;
					this.roleAddData.securityAudit = false;
					this.roleAddData.realTimeWarning = false;
					this.roleAddData.workOrder = false;
					this.roleAddData.terminalManage = false;
					this.roleAddData.releaseResourceAllow = false;
					this.roleAddData.policyRelease = false;
					this.roleAddData.systemAudit = false;
					this.roleAddData.securityProtective = false;
					this.roleAddData.syslogConfig = false;
					this.roleAddData.systemConfig = false;
					this.roleAddData.monitor = false;
				}
			},
			immediate: true,
			deep: true,
		},
	},
	methods: {
		// 搜索
		searchEvent() {
			console.log(this.searchValue);
			this.currentPage = 1;
			this.total = 0;
			this.pageSize = 10;
			this.pageNum = 1;
			this.roleSearchInfo(this.pageNum, this.pageSize, this.searchValue);
		},
		// 分页组件事件
		handleSizeChange(val) {
			console.log(`每页 ${val} 条`);
		},
		handleCurrentChange(val) {
			console.log(`当前页: ${val}`);
			if (this.searchValue != "") {
				this.roleSearchInfo(val, this.pageSize, this.searchValue);
			} else {
				this.roleAllInfo(val, this.pageSize);
			}
		},
		// true0  false1  相互转换
		transitionData(val) {
			var returnVal;
			if (val === 0) {
				returnVal = true;
			} else if (val === 1) {
				returnVal = false;
			} else if (val === true) {
				returnVal = 0;
			} else if (val === false) {
				returnVal = 1;
			}
			return returnVal;
		},
		// 0无权限  1有权限  菜单权限
		transitionMenu(val) {
			var returnVal;
			if (val === 0) {
				returnVal = false;
			} else if (val === 1) {
				returnVal = true;
			} else if (val === true) {
				returnVal = 1;
			} else if (val === false) {
				returnVal = 0;
			}
			return returnVal;
		},
		// 新增
		roleAdd() {
			this.alertBoxAddVisible = true;
		},
		// 初始化新增数据
		initAddData() {
			this.roleAddData = {
				roleName: "",
				roleNumber: "",
				roleDes: "",
				roleState: false,
				homePage: false,
				securityAudit: false,
				realTimeWarning: false,
				workOrder: false,
				terminalManage: false,
				releaseResourceAllow: false,
				policyRelease: false,
				systemAudit: false,
				securityProtective: false,
				syslogConfig: false,
				systemConfig: false,
				monitor: false,
				monitorApprove: false,
			};
		},
		// 新增确定
		roleAddConfirm() {
			if (
				this.roleAddData.homePage == false &&
				this.roleAddData.securityAudit == false &&
				this.roleAddData.realTimeWarning == false &&
				this.roleAddData.workOrder == false &&
				this.roleAddData.terminalManage == false &&
				this.roleAddData.releaseResourceAllow == false &&
				this.roleAddData.policyRelease == false &&
				this.roleAddData.systemAudit == false &&
				this.roleAddData.securityProtective == false &&
				this.roleAddData.syslogConfig == false &&
				this.roleAddData.systemConfig == false &&
				this.roleAddData.monitor == false &&
				this.roleAddData.monitorApprove == false
			) {
				this.$msg.warning("请选择授权菜单！");
			} else {
				system_role_add({
					roleName: this.roleAddData.roleName,
					serialNumber: this.roleAddData.roleNumber,
					note: this.roleAddData.roleDes,
					status: this.transitionData(this.roleAddData.roleState),
					homePage: this.transitionMenu(this.roleAddData.homePage),
					securityAudit: this.transitionMenu(this.roleAddData.securityAudit),
					realTimeWarning: this.transitionMenu(this.roleAddData.realTimeWarning),
					workOrder: this.transitionMenu(this.roleAddData.workOrder),
					terminalManage: this.transitionMenu(this.roleAddData.terminalManage),
					releaseResourceAllow: this.transitionMenu(this.roleAddData.releaseResourceAllow),
					policyRelease: this.transitionMenu(this.roleAddData.policyRelease),
					systemAudit: this.transitionMenu(this.roleAddData.systemAudit),
					securityProtective: this.transitionMenu(this.roleAddData.securityProtective),
					syslogConfig: this.transitionMenu(this.roleAddData.syslogConfig),
					systemConfig: this.transitionMenu(this.roleAddData.systemConfig),
					monitor: this.transitionMenu(this.roleAddData.monitor),
					monitorApprove: this.transitionMenu(this.roleAddData.monitorApprove),
				}).then((res) => {
					console.log(res);
					if (res.code == 200) {
						this.$msg.success("角色新增成功！");
						this.initAddData();
						this.alertBoxAddVisible = false;
						this.currentPage = 1;
						this.total = 0;
						this.pageSize = 10;
						this.pageNum = 1;
						this.roleAllInfo(this.pageNum, this.pageSize);
					} else {
						this.$msg.error("角色新增失败！");
					}
				});
			}
		},
		// 编辑
		handleEdit(index, row) {
			console.log(index, row);
			this.alertBoxIssueVisible = true;
			this.roleEdit = {
				roleId: row.id,
				roleName: row.roleName,
				roleNumber: row.serialNumber,
				roleDes: row.note,
				roleState: this.transitionData(row.status),
				roleEndtime: row.updateLastTime,
				homePage: this.transitionMenu(row.homePage),
				securityAudit: this.transitionMenu(row.securityAudit),
				realTimeWarning: this.transitionMenu(row.realTimeWarning),
				workOrder: this.transitionMenu(row.workOrder),
				terminalManage: this.transitionMenu(row.terminalManage),
				releaseResourceAllow: this.transitionMenu(row.releaseResourceAllow),
				policyRelease: this.transitionMenu(row.policyRelease),
				systemAudit: this.transitionMenu(row.systemAudit),
				securityProtective: this.transitionMenu(row.securityProtective),
				syslogConfig: this.transitionMenu(row.syslogConfig),
				systemConfig: this.transitionMenu(row.systemConfig),
				monitor: this.transitionMenu(row.monitor),
				monitorApprove: this.transitionMenu(row.monitorApprove),
			};
		},
		// 监控组change事件
		handleMonitor(newVal) {
			if (newVal) {
				this.roleEdit.homePage = false;
				this.roleEdit.securityAudit = false;
				this.roleEdit.realTimeWarning = false;
				this.roleEdit.workOrder = false;
				this.roleEdit.terminalManage = false;
				this.roleEdit.releaseResourceAllow = false;
				this.roleEdit.policyRelease = false;
				this.roleEdit.systemAudit = false;
				this.roleEdit.securityProtective = false;
				this.roleEdit.syslogConfig = false;
				this.roleEdit.systemConfig = false;
				// this.roleEdit.monitorApprove = false;
			}
		},
		// 监控组管理员change事件
		handleMonitorApprove(newVal) {
			if (newVal) {
				this.roleEdit.homePage = false;
				this.roleEdit.securityAudit = false;
				this.roleEdit.realTimeWarning = false;
				this.roleEdit.workOrder = false;
				this.roleEdit.terminalManage = false;
				this.roleEdit.releaseResourceAllow = false;
				this.roleEdit.policyRelease = false;
				this.roleEdit.systemAudit = false;
				this.roleEdit.securityProtective = false;
				this.roleEdit.syslogConfig = false;
				this.roleEdit.systemConfig = false;
				this.roleEdit.monitor = true;
			} else {
				this.roleEdit.homePage = false;
				this.roleEdit.securityAudit = false;
				this.roleEdit.realTimeWarning = false;
				this.roleEdit.workOrder = false;
				this.roleEdit.terminalManage = false;
				this.roleEdit.releaseResourceAllow = false;
				this.roleEdit.policyRelease = false;
				this.roleEdit.systemAudit = false;
				this.roleEdit.securityProtective = false;
				this.roleEdit.syslogConfig = false;
				this.roleEdit.systemConfig = false;
				this.roleEdit.monitor = false;
			}
		},
		// 编辑确定
		handleEditConfirm() {
			if (
				this.roleEdit.homePage == false &&
				this.roleEdit.securityAudit == false &&
				this.roleEdit.realTimeWarning == false &&
				this.roleEdit.workOrder == false &&
				this.roleEdit.terminalManage == false &&
				this.roleEdit.releaseResourceAllow == false &&
				this.roleEdit.policyRelease == false &&
				this.roleEdit.systemAudit == false &&
				this.roleEdit.securityProtective == false &&
				this.roleEdit.syslogConfig == false &&
				this.roleEdit.systemConfig == false &&
				this.roleEdit.monitor == false &&
				this.roleEdit.monitorApprove == false
			) {
				this.$msg.warning("请选择授权菜单！");
			} else {
				system_role_Edit({
					id: this.roleEdit.roleId,
					roleName: this.roleEdit.roleName,
					serialNumber: this.roleEdit.roleNumber,
					note: this.roleEdit.roleDes,
					status: this.transitionData(this.roleEdit.roleState),
					homePage: this.transitionMenu(this.roleEdit.homePage),
					securityAudit: this.transitionMenu(this.roleEdit.securityAudit),
					realTimeWarning: this.transitionMenu(this.roleEdit.realTimeWarning),
					workOrder: this.transitionMenu(this.roleEdit.workOrder),
					terminalManage: this.transitionMenu(this.roleEdit.terminalManage),
					releaseResourceAllow: this.transitionMenu(this.roleEdit.releaseResourceAllow),
					policyRelease: this.transitionMenu(this.roleEdit.policyRelease),
					systemAudit: this.transitionMenu(this.roleEdit.systemAudit),
					securityProtective: this.transitionMenu(this.roleEdit.securityProtective),
					syslogConfig: this.transitionMenu(this.roleEdit.syslogConfig),
					systemConfig: this.transitionMenu(this.roleEdit.systemConfig),
					monitor: this.transitionMenu(this.roleEdit.monitor),
					monitorApprove: this.transitionMenu(this.roleEdit.monitorApprove),
				}).then((res) => {
					console.log(res);
					if (res.code == 200) {
						this.$msg.success("角色修改成功！");
						this.alertBoxIssueVisible = false;
						this.currentPage = 1;
						this.total = 0;
						this.pageSize = 10;
						this.pageNum = 1;
						this.roleAllInfo(this.pageNum, this.pageSize);
					} else if (res.code == 7007) {
						this.$msg.error("内置角色不可修改！");
					} else {
						this.$msg.error("角色修改失败！");
					}
				});
			}
		},
		// 更多
		handleCommand(command) {
			console.log(command);
			if (command.value == "授权菜单") {
				console.log("授权菜单");
			} else if (command.value == "删除") {
				console.log("删除");
				this.handleDelete(command.obj);
			}
		},
		// 授权菜单
		handleMenu(index, row) {
			console.log(index, row);
		},
		// 删除
		handleDelete(obj) {
			console.log(obj);
			system_role_delete({
				id: obj.id,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("角色删除成功！");
					this.currentPage = 1;
					this.total = 0;
					this.pageSize = 10;
					this.pageNum = 1;
					this.roleAllInfo(this.pageNum, this.pageSize);
				} else if (res.code == 7006) {
					this.$msg.error("内置角色不能删除！");
				} else {
					this.$msg.error("角色删除失败！");
				}
			});
		},
		// 开关
		handleSwitch(newValue) {
			console.log(newValue);
		},
		// alertBox——详情 关闭
		alertBoxFormclose() {
			this.alertBoxIssueVisible = false;
		},
		// alertBox——新增 关闭
		alertBoxAddclose() {
			this.initAddData();
			this.alertBoxAddVisible = false;
		},
		// 查询所有角色
		roleAllInfo(page, size) {
			system_role_all({
				page: page,
				size: size,
			}).then((res) => {
				console.log(res);
				this.tableData = res.data.result;
				this.total = res.data.total;
			});
		},
		// 搜索角色
		roleSearchInfo(page, size, value) {
			system_role_all({
				page: page,
				size: size,
				keyword: value,
			}).then((res) => {
				console.log(res);
				this.tableData = res.data.result;
				this.total = res.data.total;
			});
		},
	},
};
</script>
<style lang="less" scoped>
.systemRolePage {
	width: 100%;
	height: 100%;
	padding: 12px 20px;
	box-sizing: border-box;
	background: #ffffff;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: center;
	.strategyMenus {
		width: 100%;
		height: 48px;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		.listAdd {
			flex: 1;
			height: 100%;
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: center;
			[class*="wj-button-"] {
				font-size: 14px;
				padding: 12px 18px;
			}
		}
		.strategyMenusBut {
			width: 5%;
			height: 100%;
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: center;
			[class*="wj-button-"] {
				font-size: 14px;
				padding: 12px 18px;
				margin: 0 12px;
			}
		}
		.strategyMenusSearch {
			width: 15%;
			height: 100%;
			display: flex;
			flex-direction: row;
			justify-content: flex-end;
			align-items: center;
			/deep/ .el-input {
				font-size: 16px;
			}
		}
	}
	.strategyList {
		width: 100%;
		height: calc(100% - 48px - 48px);
		padding: 28px 0;
		box-sizing: border-box;

		.listContent {
			width: 100%;
			height: 100%;

			/deep/ .el-table {
				border-left: 1px solid #ebeef5;
				border-right: 1px solid #ebeef5;
				border-top: 1px solid #ebeef5;
			}
			/deep/ .el-link {
				margin: 0 12px 0 0;
			}
			/deep/ .el-table th.el-table__cell {
				background: #ebeef5;
				font-size: 15px;
			}
			[class*="wj-button-"] {
				font-size: 14px;
				padding: 8px 18px;
			}
		}
	}
	.strategyPage {
		width: 100%;
		height: 48px;
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		align-items: center;
	}
}
</style>
